﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using RedisDemo.Entitys;
using RedisDemo.Redis.Base;
using RedisDemo.Service.IServices;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace RedisDemo.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class UserController : ControllerBase
    {
        private readonly IUserService _userService;
        private readonly RedisConfig _redis;

        public UserController(IUserService userService, RedisConfig redis)
        {
            _userService = userService;
            _redis = redis;
        }


        [HttpGet("id")]
        public async Task<IActionResult> GetAllUsers(int id)
        {
            Account account = await _userService.GetAllUsers(id);
            return Ok(account);
        }

   

        [HttpGet]
        public IActionResult Test()
        {
            _redis.Set("hello", "CodeMan");
            string value = _redis.Get("hello");
            return Ok(value);
        }

    }
}
